<template>
  <div class="box">
    <div class="search">
      <span>订单编号：</span>
      <el-input v-model="input" placeholder="请输入订单编号"></el-input>
      <span>选择日期：</span>
      <el-date-picker
        v-model="value1"
        type="daterange"
        range-separator="~"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
      </el-date-picker>
      <el-button type="primary" icon="el-icon-search">查询</el-button>
    </div>
    <div class="table">
      <el-table
        highlight-current-row
        @current-change="handleCurrentChange"
        :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
        style="width: 100%"
      >
        <el-table-column prop="date" label="序号" width="180"></el-table-column>
        <el-table-column prop="name" label="订单编号" width="180"></el-table-column>
        <el-table-column prop="name" label="商品名称" width="180"></el-table-column>
        <el-table-column prop="name" label="订单金额(元)" width="180"></el-table-column>
        <el-table-column prop="name" label="设备编号" width="180"></el-table-column>
        <el-table-column prop="name" label="订单状态" width="180"></el-table-column>
        <el-table-column prop="name" label="订单日期" width="180"></el-table-column>
        <el-table-column prop="address" label="操作"> </el-table-column>
      </el-table>
    </div>
    <div class="block">
    <el-pagination
    ref="aaa"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-size="pageSize"
      layout="total"
      :total="tableData.length"
      style="display:inline-block">
    </el-pagination>
    <span>第{{this.currentPage}}/{{this.tableData.length}}页</span>
    <el-button @click="prev">上一页</el-button>
    <el-button @click="next">下一页</el-button>
  </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        },
        {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }
      ],
      currentPage: 1,
      pageSize: 1
    }
  },
  methods: {
    prev () {
      this.$refs.aaa.handleCurrentChange(this.currentPage - 1)
    },
    next () {
      this.$refs.aaa.handleCurrentChange(this.currentPage + 1)
    }
  }
}
</script>

<style lang="scss" scoped>
.box {
  .search {
    .el-input {
      display: inline-block;
      width: 200px;
      margin-right: 10px;
    }
    .el-button {
      background-color: #5F84FF;
      margin-left: 10px;
    }
  }
}
</style>
